#!/bin/bash 
set -e

TMP=${TMP:-/tmp/work}
LOG=${LOG:-$HOME/logs/stage3}
SRC=${SRC:-/sources}

name=inetutils
version=2.0

rm -rf $TMP
mkdir -p $TMP $LOG

tar xf $SRC/$name-$version.tar.xz -C $TMP

{ time \
   {

    cd $TMP/$name-$version
    
	./configure --prefix=/usr        \
	            --localstatedir=/var \
	            --disable-logger     \
	            --disable-whois      \
	            --disable-rcp        \
	            --disable-rexec      \
	            --disable-rlogin     \
	            --disable-rsh        \
	            --disable-servers
    
    make
    
    make install
    
	mv -v /usr/bin/{hostname,ping,ping6,traceroute,ifconfig} /bin

    }
} 2>&1 | tee $name.log
    
[ $PIPESTATUS = 0 ] && mv $name.log $LOG || exit $PIPESTATUS

rm -fr $TMP
